-
Notifications
You must be signed in to change notification settings - Fork 231
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add ts file for Macaulay2Web syntax highlighting #3463
Conversation
for the record, I can't request a review. |
Should we keep the .js file around? And should we update the webpack config to build from the .ts file instead? |
what is the use of the webpack file? |
It generates the minified prism.js that ships with the Style package: https://macaulay2.com/doc/Macaulay2/share/Macaulay2/Style/prism.js |
I see. you could use the ts file instead, but I don't think that'd be useful... |
Why don't you think it would be useful? I think it would be nice to have just a single source file for the prism grammar that both Macaulay2Web and the Style package can use. |
I see. I just meant that there's no obvious benefit to switching to typescript, but yes, it should work equally well. |
@@ -0,0 +1,32 @@ | |||
import Prism from "prismjs"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we include this line? It wasn't before, and it doesn't appear that other prism language definition files include it: https://github.com/PrismJS/prism/tree/master/components
the |
Seems a bit strange to have both a .ts file and a .js file for prism, I'd rather just have one, but if we must have two, then they should have the same symbols/variables defined. |
I actually don't see anything TypeScript-specific in the new file -- it's just exactly the .js file with the I agree that import Prism from 'prismjs';
import 'path/to/macaulay2.js';
// maybe do some other stuff |
I don't think that's how it works in typescript. |
I think Doug's point is that the user should have called |
Yeah, you're right, Paul -- it's a TypeScript thing. I removed the
But if I rename prism-M2.ts -> prism-M2.js, webpack runs just fine. So why not just keep it as a .js file, especially since it doesn't use anything specific to TypeScript? That way, Macaulay2Web, the Style package, and potentially other users that want to use prism for highlighting M2 code could use it. |
are you sure this works in ordinary js? in other words, I've no idea how a browser handles an |
Oh yeah, that's a good point -- Despite the convenience of having them together in the same file, I'm almost wondering if the symbols should go in another file? They're not really related to syntax highlighting with Prism. |
yes, let me think about that. |
OK. now there is a separate file for the symbols used by Macaulay2Web. |
f7dabde removed a line from
macaulay2.js.in
which was used by Macaulay2Web.Since Macaulay2Web uses typescript anyway, a new file
macaulay2.ts.in
is created with the missing line put back, and a comment that it's used by Macaulay2Web.